<template>
	<view class="content">
		<view class="match-top-box">
			<view class="match-title">尊敬的委托人：</view>
			<view class="match-txt">您好！{{ infoLawyer.address }}{{ infoLawyer.lawyer }}律师很荣幸接受您的委托，我们将全心全意为您提供优质的服务！感谢您的信任与支持！</view>
			<view class="match-image-txt">
				<view class="txt-left">
					<view class="image-wrapper"><image src="@/static/img/warning.png" mode="aspectFit"></image></view>
				</view>
				<view class="txt-right green">请详细阅读律师给您的委托代理合同，如有疑问， 请随时联系律师为您解答清楚。</view>
			</view>

			<template v-if="info.order.pro_name != '问一下'">
				<view class="match-image-txt">
					<view class="txt-left">
						<view class="image-wrapper"><image src="@/static/img/warning.png" mode="aspectFit"></image></view>
					</view>
					<view class="txt-right green">匹配律师成功后15分钟内，如您没有更换律师的，平台将自动在“办公”页面，为您和律师创建本订单的项目和群聊，方便您和律师沟通。</view>
				</view>
			</template>
      <template v-if="info.order.pro_name != '问一下'">
        <view class="match-image-txt">
          <view class="txt-left">
            <view class="image-wrapper"><image src="@/static/img/warning.png" mode="aspectFit"></image></view>
          </view>
          <view class="txt-right green">
            办案过程中，如发现案件依法不在该律师执业区域以内审理的，请先跟律师友好协商。如同意该律师继续代理的，请与律师沟通好异地办案的差旅费用等相关事宜。如不同意该律师继续代理的，点击下面“换个律师”按钮，返回法务服务中，由法务专员协助您换个案件管辖地的新律师，您在原订单已支付的律师费用将全额保留在您的账户里。
          </view>
        </view>
      </template>
			<template v-if="info.order.pro_name == '私人律师'">
				<view class="match-image-txt">
					<view class="txt-left">
						<view class="image-wrapper"><image src="@/static/img/time-green.png" mode="aspectFit"></image></view>
					</view>
					<view class="txt-right">
						还可咨询
						<text class="red">{{ info.order.day }}天</text>
					</view>
				</view>
			</template>
			<view class="service-list">
				<button class="service-item active" @click="$refs.telephoneLawyer.$refs.popupTel.open()">联系律师</button>
				<button class="service-item active" @click="$refs.orderAddService.$refs.popupAddService.open()" v-if="info.order.pro_name != '打官司'">增加服务</button>
				<template v-if="info.order.pro_name == '私人律师'">
					<button class="service-item active" @click="$refs.orderButlerRenew.$refs.popupRenew.open()">私人律师续期</button>
				</template>
				<template v-if="info.order.pro_name != '问一下'">
					<button class="service-item active" @click="$refs.popupPayToLaw.open()">付款给律师</button>
				</template>
				<button class="service-item active" @click="jump('/pages/client/user/invoice', { order_id: order_id })">开发票</button>
				<button class="service-item active" :disabled="isClientServiceOk || isLawyerServiceOk || disableServiceOk" @click="$refs.popupServiceOk.open">服务完成</button>
				<button class="service-item active" :disabled="isClientRemoveEntrust || isLawyerRemoveEntrust || disableRemoveEntrust" @click="removeEntrust">解除委托</button>
				<template v-if="info.order.pro_name != '问一下'">
					<!-- <button class="service-item active" v-if="info.order.usergroupid" @click="navToChat(info.order.usergroupid )">办理详情</button> -->
				</template>
				<button class="service-item active" :disabled="info.order.is_over != 1 || info.order.status==21||info.order.status==22 || isClientServiceOk || isLawyerServiceOk || disableServiceOk || isClientRemoveEntrust || isLawyerRemoveEntrust || disableRemoveEntrust" @click="$refs.popupCheckLaw.open()">换个律师</button>
				<template v-if="info.order.status==21">
					<view class="service-list"  style="padding-top: 0rpx;">
					<button class="service-item active flex1" style="" @click="$refs.popupCancelLaw.open()">取消更换律师</button>
					<button class="service-item active flex1" style="margin-right: 0;" @click="$refs.telephoneLawyer.$refs.popupTel.open()">催促律师确认更换</button>
					</view>
				</template>
				<template v-if="info.order.status==22">
					<view class="service-list" style="padding-top: 0rpx;">
						<button class="service-item active flex1" @click="$refs.popupBackLaw.open()">退回更换律师申请</button>
						<button class="service-item active flex1" style="margin-right: 0;" @click="$refs.popupAgreeLaw.open()">确认更换律师</button>
					</view>
				</template>
				<button class="service-item active" style="width: 100%; margin-right: 0;" v-if="!isTimeOver && lvShiTime" @click="$refs.orderChangeLawyer.$refs.popupChangeLawyer.open()">
					<uni-countdown
						:show-day="false"
						:hour="lvShiTime.hour"
						:minute="lvShiTime.minute"
						:second="lvShiTime.second"
						color="#f00"
						splitorColor="#f00"
						backgroundColor="#FFC801"
						@timeup="timeup"
					></uni-countdown>
					无理由更换律师
				</button>
				<button class="service-item active" v-if="isClientServiceOk" style="width: 100%; margin-right: 0;" @click="$refs.telephoneLawyer.$refs.popupTel.open()">
					催促律师确认完成
				<!-- 	{{info.order.lawyer_time}} -->
					<template v-if="info.order.lawyer_finish">
						<uni-countdown
							:show-day="false"
							:hour="remainTime.hour"
							:minute="remainTime.minute"
							:second="remainTime.second"
							color="#f00"
							splitorColor="#f00"
							backgroundColor="#FFC801"
							@timeup="timeup"
						></uni-countdown>
					</template>

				</button>
				<button class="service-item active" v-if="isClientRemoveEntrust" style="width: 100%; margin-right: 0;" @click="$refs.telephoneLawyer.$refs.popupTel.open()">
					催促律师确认解除
				</button>
				<button class="service-item active" v-if="isClientServiceOk || isClientRemoveEntrust" style="width: 100%; margin-right: 0;" @click="$refs.popupCancelServiceApply.open()">
					取消申请
				</button>
			</view>

			<template v-if="isLawyerRemoveEntrust">
				<view class="service-list">
					<button class="service-item active flex1" @click="$refs.popupSureRemoveEntrust.open()">确认解除委托</button>
					<button class="service-item active flex1" style="margin-right: 0;" @click="$refs.popupNoSureRemoveEntrust.open()">退回申请</button>
				</view>
			</template>
			<!-- <template v-if="isLawyerServiceOk"> -->
				<view class="service-list">
					<button v-if="isLawyerServiceOk" class="service-item active" style="width: 100%;margin-right: 0;"  @click="$refs.popupSureServiceOk.open()">
						确认服务完成<uni-countdown
						:show-day="false"
						:hour="remainTime.hour"
						:minute="remainTime.minute"
						:second="remainTime.second"
						color="#f00"
						splitorColor="#f00"
						backgroundColor="#FFC801"
						@timeup="timeup"
					></uni-countdown></button>
					<button v-if="isLawyerServiceOk" class="service-item active" style="width: 100%;margin-right: 0;" @click="$refs.popupNoSureServiceOk.open()">退回申请</button>
				</view>
			<!-- </template> -->
		</view>
		<!-- 待付信息 -->
		<!-- <order-wait-pay-info v-if="Object.keys(info.order).length > 0" :info="info" @init="init"></order-wait-pay-info> -->
		<!-- 付款详情 -->
		<!-- <order-common-detail v-if="Object.keys(info.order).length > 0" :detailLIst="info.order.pay_text" title="付款详情" :info="info"></order-common-detail> -->
		<!-- 待付信息
		按新版设计图直接改样式
		 -->
		<order-client-pay-info v-if="Object.keys(info.order).length > 0" :info="info" :zifei="zifei" @init="init" @popupShow="popupShow" @clearTime="clearTime"></order-client-pay-info>
		<!-- 付款详情 -->
		<order-client-detail v-if="Object.keys(info.order.pay_text).length > 0 || Object.keys(info.order.jie_pay).length > 0" :detailLIst="info.order.pay_text" title="付款详情" @popupShow="popupShow"
			:info="info"></order-client-detail>
		<!-- 增加服务详情 -->
		<order-common-detail v-if="Object.keys(info.order).length > 0" :detailLIst="info.order.server_pay" title="增加服务" :info="info"></order-common-detail>
		<!-- 续费详情 -->
		<order-common-detail v-if="Object.keys(info.order).length > 0" :detailLIst="info.order.xu_pay" title="续费详情" :info="info"></order-common-detail>
		<!-- 发票列表组件-->
		<order-invoice-invest v-if="Object.keys(info.order).length > 0" :info="info" @init="init"></order-invoice-invest>
		<!-- 律师简介 -->
		<order-lawyer-intro v-if="Object.keys(infoLawyer).length > 0" :infoLawyer="infoLawyer" :random="new Date().getTime()"></order-lawyer-intro>
		<!-- 案件主体信息 -->
		<order-case :info="info" :key="new Date().getTime() + 'case'" :statused="statused" v-if="info.order.pro_name == '打官司'"></order-case>
		<!-- 订单详情  -->
		<order-detail ref="orderAllDetail" :info="info.order"></order-detail>
		<!-- 解除委托-未付款弹出层 -->
		<uni-popup ref="popupRemoveEntrust" type="dialog">
			<uni-popup-dialog type="info" title="" okTxt="我知道了" cancleTxt="" content="" :before-close="true" @confirm="closePop('popupRemoveEntrust')">
				<view class="warm-tip-box">
					<view class="warm-tip-item">为保障您及您好友推荐本平台应得的奖励，请按照以下流程解除和退款：</view>
					<view class="warm-tip-item">
						<view class="item-left">1</view>
						<view class="item-right">在本平台“办公”→“信息”→本订单“委托人协作团队”群聊里，与律师确定解除和退款事宜，保留聊天记录；</view>
					</view>
					<view class="warm-tip-item">
						<view class="item-left">2</view>
						<view class="item-right">在“待付信息”里，付清剩余律师费用；</view>
					</view>
					<view class="warm-tip-item">
						<view class="item-left">3</view>
						<view class="item-right">再次点击“解除委托”按钮，发起解除；</view>
					</view>
					<view class="warm-tip-item">
						<view class="item-left">4</view>
						<view class="item-right">联系律师，确认解除委托；</view>
					</view>
					<view class="warm-tip-item">
						<view class="item-left">5</view>
						<view class="item-right">律师确认后，您将进入“服务解除”页面。如需退款的，可在该页面点击“申请退款”按钮办理。</view>
					</view>
				</view>
			</uni-popup-dialog>
		</uni-popup>
		<!-- 解除委托 弹出层-->
		<uni-popup ref="popupRemoveEntrustReason" type="dialog">
			<uni-popup-dialog-reason
				type="info"
				title=""
				okTxt="确认"
				cancleTxt="取消"
				:showClose="false"
				:before-close="true"
				@confirm="
					confirmReason();
				"
				@close="closePop('popupRemoveEntrustReason')"
			>
				<view class="return-reason-box">
					<view class="return-tip">解除原因<text style="color:red">*</text></view>

					<textarea class="textarea-border textarea-height" placeholder="把解除原因告诉律师吧，让律师改进工作！" placeholder-class="placeholder" v-model="reason" />
				</view>

				<view class="entrust-tip">我已与律师确认解除委托</view>
			</uni-popup-dialog-reason>
		</uni-popup>

		<!-- 确认解除委托弹出层 -->
		<uni-popup ref="popupSureRemoveEntrust" type="dialog">
			<uni-popup-dialog
				type="info"
				okTxt="是"
				cancleTxt="否"
				:before-close="true"
				@confirm="sureRemoveEntrust(1, 'popupSureRemoveEntrust')"
				@close="closePop('popupSureRemoveEntrust')"
			>
				<view class="dialog-tip">解除委托原因：</view>
				<view class="dialog-tip">{{ info.order.lawyer_remove }}</view>
				<view class="dialog-tip-line">我确认解除委托</view>
			</uni-popup-dialog>
		</uni-popup>
		<!-- 不确认解除委托弹出层 -->
		<uni-popup ref="popupNoSureRemoveEntrust" type="dialog">
			<uni-popup-dialog
				type="info"
				okTxt="是"
				cancleTxt="否"
				:before-close="true"
				@confirm="sureRemoveEntrust(2, 'popupNoSureRemoveEntrust')"
				@close="closePop('popupNoSureRemoveEntrust')"
			>
				<view class="dialog-tip">解除原因：</view>
				<view class="dialog-tip">{{ info.order.lawyer_remove }}</view>
				<view class="dialog-tip-line">我确认退回申请</view>
			</uni-popup-dialog>
		</uni-popup>
		<!-- 服务完成弹出层 -->
		<uni-popup ref="popupServiceOk" type="dialog">
			<uni-popup-dialog
				type="info"
				okTxt="是"
				cancleTxt="否"
				content="我已与律师确认服务完成"
				:before-close="true"
				@confirm="confirmServiceOk"
				@close="closePop('popupServiceOk')"
			></uni-popup-dialog>
		</uni-popup>
		<!-- 确认服务完成弹出层 -->
		<uni-popup ref="popupSureServiceOk" type="dialog">
			<uni-popup-dialog
				type="info"
				okTxt="是"
				cancleTxt="否"
				content="我确认服务已经完成"
				:before-close="true"
				@confirm="sureServiceOk(1, 'popupSureServiceOk')"
				@close="closePop('popupSureServiceOk')"
			></uni-popup-dialog>
		</uni-popup>
		<!-- 不确认服务完成弹出层 -->
		<uni-popup ref="popupNoSureServiceOk" type="dialog">
			<uni-popup-dialog
				type="info"
				okTxt="是"
				cancleTxt="否"
				content="确认退回申请"
				:before-close="true"
				@confirm="sureServiceOk(2, 'popupNoSureServiceOk')"
				@close="closePop('popupNoSureServiceOk')"
			></uni-popup-dialog>
		</uni-popup>
		<!-- 付款给律师  -->
		<uni-popup ref="popupPayToLaw">
			<service-popup-pay title="我要付款" btnText="我要支付" @closePop="closePop('popupPayToLaw')" @confirmPay="confirmPayToLaw">
				<template slot="payOption">
					<view class="od-box" style="width: 100%; padding: 0;">
						<view class="od-item marginbottom20">
							<view class="item-tip require">付款金额</view>
							<view class="item-right">
								<view class="item-txt"><input type="number" class="ipt-border" placeholder="请输入" placeholder-class="placeholder" v-model="payToPrice" /></view>
							</view>
						</view>
						<view class="od-item marginbottom20">
							<view class="item-tip require">付款事由</view>
							<view class="item-right">
								<view class="item-txt"><textarea auto-height="true" class="textarea-border" placeholder="请输入" placeholder-class="placeholder" v-model="payToReason" /></view>
							</view>
						</view>
					</view>
				</template>
			</service-popup-pay>
		</uni-popup>
		<!-- 增加服务-线下面谈 弹出层 -->
		<order-add-service ref="orderAddService" :info="info" v-if="Object.keys(info.order).length > 0" @init="init"></order-add-service>
		<!-- 私人律师续期组件 -->
		<order-butler-renew ref="orderButlerRenew" v-if="info.order.pro_name == '私人律师' && Object.keys(info.order).length > 0" :info="info" @init="init"></order-butler-renew>
		<!-- 打电话组件 -->
		<order-telephone name="委托人" :phoneNumber="info.order.user_mobile" ref="telephoneClient" v-if="info.order.user_mobile"></order-telephone>
		<order-telephone name="律师" :phoneNumber="info.order.lawyer_mobile" ref="telephoneLawyer" v-if="info.order.lawyer_mobile"></order-telephone>
		<order-telephone name="投资人" :phoneNumber="info.order.investor_mobile" ref="telephoneInvestor" v-if="info.order.investor_mobile"></order-telephone>
		<!-- 无理由更换律师组件 -->
		<order-change-lawyer ref="orderChangeLawyer" v-if="Object.keys(info.order).length > 0" :info="info"></order-change-lawyer>
		<!-- 取消申请弹出层 -->
		<uni-popup ref="popupCancelServiceApply" type="dialog">
			<uni-popup-dialog
				type="info"
				okTxt="是"
				cancleTxt="否"
				:content="info.order.status == 14 ? '取消服务完成申请' : '取消服务解除申请'"
				:before-close="true"
				@confirm="
					closePop('popupCancelServiceApply');
					cancleApplyService();
				"
				@close="closePop('popupCancelServiceApply')"
			></uni-popup-dialog>
		</uni-popup>
		<!-- 全局通用组件 -->
		<law-common ref="lawCommon"></law-common>
		<!-- 律师请款 -->
		<lawyer-qing ref="lawyerQing" :item="current_item"></lawyer-qing>
		<!--    律师请款2-->
		<lawyer-qing2 ref="lawyerQing2" :item="current_item"></lawyer-qing2>
		<lawyer-qing3 ref="lawyerQing3" :item="current_item"></lawyer-qing3>
		<!-- 更换律师弹框 -->
		<uni-popup ref="popupCheckLaw">
			<view class="check-back">
				<view style="display: flex;align-items: center;justify-content: center;position: relative">
					<view class=""></view>
					<view class="check-title">更换律师</view>
					<view class="close-img" style="position: absolute;right: 10rpx" @click="$refs.popupCheckLaw.close()">
						<image src="@/static/img/close.png" mode="aspectFit" style="width: 100%;height: 100%;"></image>
					</view>
				</view>
				<view style="margin-top: 40rpx;margin-left: 30rpx;">
					<view class="check-title" style="font-weight: normal">更换理由<span style="color: red;">*</span></view>
					<view class="list-item" @click="cause(0)">
						<image src="../../../static/img/icon/radio.png" v-if="causeOne==false" style="width: 30rpx;height: 30rpx;"></image>
						<image src="../../../static/img/icon/radioed.png" v-else style="width: 30rpx;height: 30rpx;"></image>
						<view style="margin-left: 10rpx;">法院不予立案</view>
					</view>
					<view class="list-item" @click="cause(1)">
						<image src="../../../static/img/icon/radio.png" v-if="causeTwo==false" style="width: 30rpx;height: 30rpx;"></image>
						<image src="../../../static/img/icon/radioed.png" v-else style="width: 30rpx;height: 30rpx;"></image>
						<view style="margin-left: 10rpx;">案件移送异地审理</view>
					</view>
					<view class="list-item" style="align-items: flex-start">
            <view @click="cause(2)" style="display: flex;justify-content: flex-start;align-content: center;">
              <image src="../../../static/img/icon/radio.png" v-if="causeThree==false" style="width: 30rpx;height: 30rpx;margin-top: 6rpx;"></image>
              <image src="../../../static/img/icon/radioed.png" v-else style="width: 30rpx;height: 30rpx;margin-top: 6rpx;"></image>
              <view style="margin-left: 10rpx;display: flex;align-items: flex-start;">
                <view style="width: 70rpx;">其他</view>
            </view>
            </view>

            <!-- <textarea class="textarea-border textarea-height" placeholder="输入其他事由" placeholder-class="placeholder" v-model="causeThreeTxt" /> -->
            <textarea placeholder="输入其他事由" v-model="causeThreeTxt" auto-height style="margin-left: 5rpx;border-bottom: 1rpx solid black;width: calc(100% - 70rpx);" />

					</view>
				</view>
				<view style="text-align: center;margin-top: 50rpx;">我已与律师协商好换个律师</view>
				<view :class="getCauseStatus() ? 'btn' : 'dis-btn-box'" @click="checkLaws">换个律师</view>

			</view>
		</uni-popup>
		<!-- 取消更换律师弹框 -->
		<uni-popup ref="popupCancelLaw" type="dialog">
			<uni-popup-dialog
				type="info"
				okTxt="是"
				cancleTxt="否"
				title="确认取消更换"
				:before-close="true"
				@confirm="
					closePop('popupCancelLaw');
					cancelLaws();
				"
				@close="closePop('popupCancelLaw')"
			>
			<!-- <view class="dialog-tip">更换律师原因：</view>
			<view class="dialog-tip">
				{{info.order.change_type==3?info.order.change_reason:info.order.change_type==2?'案件移送异地审理':'法院不予立案'}}
			</view> -->
			</uni-popup-dialog>
		</uni-popup>
		<!-- 退回委托人更换律师弹框 -->
		<uni-popup ref="popupBackLaw" type="dialog">
			<uni-popup-dialog
				type="info"
				okTxt="是"
				cancleTxt="否"
				title="退回更换律师申请"
				:before-close="true"
				@confirm="
					closePop('popupBackLaw');
					lawBack();
				"
				@close="closePop('popupBackLaw')"
			>
			<view class="dialog-tip">更换律师原因：</view>
			<view class="dialog-tip">
				{{info.order.change_type==3?info.order.change_reason:info.order.change_type==2?'案件移送异地审理':'法院不予立案'}}
			</view></uni-popup-dialog>
			<!-- <view class="check-back-box">
				<view style="display: flex;align-items: center;justify-content: space-between;">
					<view class=""></view>
					<view class="check-title">退回更换律师申请</view>
					<view class="close-img" >
					</view>
				</view>
			<view class="dialog-tip" style="margin-top: 10px;">更换律师原因：</view>
			<view class="dialog-tip" style="margin-left: 20rpx;">
				{{info.order.change_type==3?info.order.change_reason:info.order.change_type==2?'案件移送异地审理':'法院不予立案'}}
			</view>
			<view class="btn-box">
				<view class="btn-item" @click="closePop('popupBackLaw')">
					否
				</view>
				<view class="btn-item" @click="
					closePop('popupBackLaw');
					lawBack();
				">
					是
				</view>
			</view>
			</view> -->
		</uni-popup>
		<!-- 同意委托人更换律师弹框 -->
		<uni-popup ref="popupAgreeLaw" type="dialog">
			<uni-popup-dialog
				type="info"
				okTxt="是"
				cancleTxt="否"
				title="确认更换律师"
				:before-close="true"
				@confirm="
					closePop('popupAgreeLaw');
					lawAgree();
				"
				@close="closePop('popupAgreeLaw')"
			><view class="dialog-tip">更换律师原因：</view>
			<view class="dialog-tip">
				{{info.order.change_type==3?info.order.change_reason:info.order.change_type==2?'案件移送异地审理':'法院不予立案'}}
			</view></uni-popup-dialog></uni-popup-dialog>
			<!-- <view class="check-back-box">
				<view style="display: flex;align-items: center;justify-content: space-between;">
					<view class=""></view>
					<view class="check-title">确认更换律师</view>
					<view class="close-img" >
					</view>
				</view>
			<view class="dialog-tip" style="margin-top: 10px;">更换律师原因：</view>
			<view class="dialog-tip" style="margin-left: 20rpx;">
				{{info.order.change_type==3?info.order.change_reason:info.order.change_type==2?'案件移送异地审理':'法院不予立案'}}
			</view>
			<view class="btn-box">
				<view class="btn-item" @click="closePop('popupAgreeLaw')">
					否
				</view>
				<view class="btn-item" @click="
					closePop('popupAgreeLaw');
					lawAgree();
				">
					是
				</view>
			</view>
			</view> -->
		</uni-popup>
	</view>
</template>

<script>
import { mixin } from '@/common/mixins/face_order_state.js';
import { share_coupon } from '@/common/mixins/share_coupon.js';
import {
	mapGetters
} from 'vuex';
export default {
	mixins: [mixin, share_coupon],
	data() {
		return {
			info: {
				order: {}
			},
			current_item:{},
			order_id: '',
			remainTime: {}, //剩余时间
			isTimeOver: true, //倒计时结束
			infoLawyer: {},
			reason: '',
			payToPrice: '', //付款给律师-金额
			payToReason: '', //付款给律师-原因
			timeing: false ,//是否正在倒计时
			causeOne:false, //更换律师理由一
			causeTwo:false,//更换律师理由二
			causeThree:false ,//更换律师理由三
			causeThreeTxt:'',//更换律师理由三 文本内容
      zifei:'1',
	  lvShiTime:{},
      statused:''

		};
	},

	computed: {
		...mapGetters(['userInfo'])
	},
	created() {
		// 安卓
		window.payOk = this.payOk;
	},
	onLoad(params) {
    if (params.status) {
      this.statused = params.status;
    }
		if (params.order_id) {
			this.order_id = params.order_id;
			this.init();
		}
	},
	onShow(){
		console.log(this.userInfo,'------userInfo')
		if(this.order_id){
			console.log("================this.info ,",this.order_id);
			this.init();
		}
	},
	methods: {
    clearTime(index){
      this.info.order.pend_text[index].isfinshed = false;
    },
		async init() {
      console.log('重载页面');
			let that = this;
			let formData = {
				id: that.order_id,
				token: uni.getStorageSync('token')
			};
			let res = await that.$api('index.orderDetail', formData);
			if (res.code == 1) {
				that.info = res.data;
				this.getOrderState(this.info);

        if (this.info.order.lawyer_finish != undefined) {
          this.remainTime = this.timeFn(this.info.order.lawyer_finish);
        }

				console.log('XXXXXXXXXX',this.info.order);
				if (this.info.order.lawyer_finish == undefined) {
					// 如果已经存在倒计时，不再走这个
					if (!this.timeing) {
						let d = that.get15MinutesLater(that.info.order.lawyer_time);
						console.log(d,'------d')
						this.lvShiTime = this.timeFn(d);
						console.log(this.lvShiTime,'------dthis.lvShiTime')
						if (this.lvShiTime.hour > 0 || this.lvShiTime.minute > 0 || this.lvShiTime.second > 0) {
							this.isTimeOver = false;
						}
						this.timeing = true;
					 }
				}
				if(this.info.order.pend_text){
          this.info.order.pend_text.forEach((item)=>{
            if(item.chaotime){
              item.isfinshed = true;
              item.lvShiTime = this.timeFn(item.chaotime);
            }
          })
        }
			}

			let formDataLawyer = {
				id: this.info.order.lawyer,
				token: uni.getStorageSync('token')
			};
			let resLawyer = await this.$api('index.lawyerDetail', formDataLawyer);
			this.infoLawyer = resLawyer.data;
		},popupShow(item) {
				if (item.type == 8) {
					this.current_item = item
          console.log("=====this.current_item",this.current_item)
					this.$refs.returnCostTip.$refs.returnCost.open()
				} else if (item.type == 3 || item.type == 1) {
					/* this.current_item = item.popup
					this.$refs.settlement.$refs.settlement.open() */
					// this.current_item = item
					// this.$refs.investShouyi.$refs.investShou.open()
					this.current_item = item
					this.$refs.investShouyi.$refs.investShou.open()
				}else if (item.type == 6 ) {
					this.current_item = item
					this.$refs.lawyerQing3.$refs.lawyerApply3.open()
				} else if (item.type == 7 ) {
					this.current_item = item.popup
					this.$refs.lawyerApply.$refs.lawyerApply.open()
				} else if (item.type == 2) {
					// 退款弹窗
					this.current_item = item.popup
					this.$refs.lawyerTui.$refs.lawyerApply.open()
				} else if (item.shou_type == 2) {
					this.current_item = item
					this.$refs.lawyerQing.$refs.lawyerApply.open()
				}
      console.log("=======this.current_item",this.current_item)
			},
		// 解除委托
		async confirmReason() {
      if(!this.reason){
        uni.showToast({
          title:'请填写解除理由',
          icon:'none',
          duration:1000
        })
        return;
      }
			let formData = {
				id: this.order_id,
				token: uni.getStorageSync('token'),
				reason: this.reason
			};
			let res = await this.$api('index.u_remove_lawyer', formData);
			if (res.code == 1) {
			  this.$refs.popupRemoveEntrustReason.close();
				this.init();
			}
		},
		// removeEntrust() {
		// 	if (this.info.order.pend_text.length > 0) {
		// 		this.$refs.popupRemoveEntrust.open();
		// 	} else {
		// 		this.$refs.popupRemoveEntrustReason.open();
		// 	}
		// },
		// 确认解除委托
		async sureRemoveEntrust(status, pop) {
			let formData = {
				id: this.order_id,
				token: uni.getStorageSync('token'),
				status: status
			};
			let res = await this.$api('index.u_lawyer_remove', formData);
			if (res.code == 1) {
				if (pop == 'popupSureRemoveEntrust') {
					this.closePop('popupSureRemoveEntrust');
					this.replace('/pages/client/user/evaluate', {
						order_id: this.order_id,
						lawyer_id: this.info.order.lawyer,
					});
				} else if (pop == 'popupNoSureRemoveEntrust') {
					this.closePop('popupNoSureRemoveEntrust');
					this.init();
				}
			}
		},
		// 15分钟倒计时结束
		timeup() {
			this.isTimeOver = true;
			if(this.isLawyerServiceOk){
				this.sureServiceOk(1,'aaa')
				this.init();
				this.jump('/pages/client/user/service-end', { order_id: this.order_id })

			}
		},
		removeEntrust() {
			if (this.info.order.pend_text.length > 0) {
				this.$refs.popupRemoveEntrust.open();
			} else {
				this.$refs.popupRemoveEntrustReason.open();
			}
		},
		async confirmServiceOk() {
			let formData = {
				id: this.order_id,
				token: uni.getStorageSync('token')
			};
			let res = await this.$api('index.u_sure_lawyer', formData);
			if (res.code == 1) {
				this.$refs.popupServiceOk.close();
				this.init();
			}
		},
		async sureServiceOk(status, pop) {
			let formData = {
				id: this.order_id,
				token: uni.getStorageSync('token'),
				status: status
			};
			let res = await this.$api('index.u_sure_lawyer_over', formData);
			if (res.code == 1) {
				if (pop == 'popupSureServiceOk') {
					this.replace('/pages/client/user/evaluate', {
						order_id: this.order_id,
						lawyer_id: this.info.order.lawyer,
					});
					return '';
					this.closePop('popupSureServiceOk');
					this.init();
				} else if (pop == 'popupNoSureServiceOk') {
					this.closePop('popupNoSureServiceOk');
					this.init();
				}
			}
		},
		// 付款给律师-支付
		async confirmPayToLaw(payMethod) {
			if (this.payToPrice < 0.01) {
				uni.showToast({
					title: '请输入正确的金额',
					icon: 'none'
				});
				return;
			}
			if (!this.payToReason) {
				uni.showToast({
					title: '请输入付款事由',
					icon: 'none'
				});
				return;
			}
			this.$refs.popupPayToLaw.close();
			let formData = {
				id: this.order_id,
				token: uni.getStorageSync('token'),
				type: 6,
				origin: this.payToReason,
				pay_type: payMethod,
				price: this.payToPrice
			};
			let res = await this.$api('index.money', formData);
			if (res.code == 1) {
				let formDataPay = {
					order_id: res.data.order_id,
					payMethod: payMethod,
					fen: '',
					pay_type: 2
				};
				let resPay = await this.$pay(formDataPay);
				if (resPay == 1) {
					uni.showToast({
						title: res.msg,
						icon: 'none'
					});
					this.init();
				}
			}
		},
		// 增加服务-支付
		async confirmAddService(payMethod) {
			this.$refs.popupAddService.close();
			let formData = {
				id: this.order_id,
				token: uni.getStorageSync('token'),
				type: 4,
				pay_type: payMethod,
				serve_time: this.serviceDuration,
				price: this.lawPrice,
				origin: '线下面谈' + this.serviceDuration
			};
			let res = await this.$api('index.money', formData);
			if (res.code == 1) {
				let formDataPay = {
					order_id: res.data.order_id,
					payMethod: payMethod,
					fen: '',
					pay_type: 2
				};
				let resPay = await this.$pay(formDataPay);
				if (resPay == 1) {
					uni.showToast({
						title: res.msg,
						icon: 'none'
					});
					this.init();
				}
			}
		},
		payOk(res) {
			// 安卓0 支付成功，-1 支付失败， -2取消支付
			if (res == '0') {
				this.init();
			}
		},
		// 委托人取消申请服务完成，服务解除
		async cancleApplyService(){
			let formData = {
				id: this.order_id,
				token: uni.getStorageSync('token')
			};
			let url = '';
			// 委托人点服务完成
			if(this.info.order.status == 14){
				url = 'index.u_cancel_sure_lawyer';
			}
			// 委托人点服务解除
			else if(this.info.order.status == 10){
				url = 'index.u_cancel_remove_lawyer';
			}
			let res = await this.$api(url, formData);
			if (res.code == 1) {
				uni.showToast({
					title: res.msg,
					icon: 'none'
				});
				this.init();
			}
		},
		//选择 更换律师理由
		cause(e){
			if(e==0){
				this.causeOne=!this.causeOne
				this.causeThree=false
				this.causeTwo=false
			}else if(e==1){
				this.causeTwo=!this.causeTwo
				this.causeThree=false
				this.causeOne=false
			}else{
				this.causeThree=!this.causeThree
				this.causeOne=false
				this.causeTwo=false
			}
		},
		getCauseStatus(){
			if(this.causeOne || this.causeTwo || this.causeThree){
				return true
			}else{
				return false
			}
		},
		//换个律师
		async checkLaws() {
			var type='';
			if(this.causeOne==true) type=1;
			if(this.causeTwo==true) type=2;
			if(this.causeThree==true) type=3;
			if(type==''){
				uni.showToast({
					title:'请选择更换理由',
					icon:'none',
					duration:1000
				})
				return;
			}
			let formData = {
				id: this.order_id,
				token: uni.getStorageSync('token'),
				type:type
			};
			if(type==3) formData.change_reason=this.causeThreeTxt
			let res = await this.$api('index.weituochange', formData);
			if (res.code == 1) {
				this.$refs.popupCheckLaw.close();
				this.init();
			}
		},
		//取消更换律师
		async cancelLaws(){
			let formData = {
				id: this.order_id,
				token: uni.getStorageSync('token')
			};
			let res = await this.$api('index.cancelweichange', formData);
			if (res.code == 1) {
				this.init();
			}
		},
		//委托人退回律师申请更换律师
		async lawBack(){
			let formData = {
				id: this.order_id,
				token: uni.getStorageSync('token')
			};
			let res = await this.$api('index.backchangelawyer', formData);
			if (res.code == 1) {
				this.init();
			}
		},
		//委托人同意律师申请更换律师
		async lawAgree(){
			let formData = {
				id: this.order_id,
				token: uni.getStorageSync('token')
			};
			let res = await this.$api('index.weituosurechange', formData);
			if (res.code == 1) {
				//this.init();
				this.replace('/pages/client/user/match-specialist', {
					order_id: this.order_id
				});
			}
		},
	}
};
</script>

<style lang="scss">
.content {
	padding-bottom: 30rpx;
}
.ok-box {
	padding: 0;
}
.service-list {
	padding-top: 20rpx;
	margin-bottom: -10px;
}
//下半部分圆角矩形
.service-item {
	border-radius: 50rpx;
}

//更换律师
.check-back{
	background-color: #FFFFFF;
	padding: 30rpx;
	border-radius: 20rpx;
	width: 600rpx;
}
//确定更换律师
.check-back-box{
	background-color: #FFFFFF;
	padding: 30rpx 30rpx 0rpx 30rpx;
	border-radius: 20rpx;
	width: 600rpx;
}
.check-title{
	font-size: 34rpx;
	font-weight: bold;
}
.close-img{
	width: 30rpx;
	height: 30rpx;
}
.list-item{
	display: flex;
	align-items: center;
	// margin-left: 20rpx;
	margin-top: 30rpx;
	width: 100%;
}
.btn{
	width: 330rpx;
	height: 60rpx;
	line-height: 60rpx;
	background-color: #FFC801;
	color: #FFFFFF;
	text-align: center;
	border-radius: 10rpx;
	margin: 0 auto;
	margin-top: 30rpx;
	margin-bottom: 20rpx;
}
.btn-box{
	width: 100%;
	height: 45px;
	display: flex;
	justify-content: center;
	.btn-item{
		width: 50%;
		height: 45px;
		line-height: 45px;
		text-align: center;
		border-right-color: #f0f0f0;
		    border-right-style: solid;
		    border-right-width: 1px;
			border-top-color: #f5f5f5;
			    border-top-style: solid;
			    border-top-width: 1px;
	}
}
.dis-btn-box{
	width: 330rpx;
	height: 60rpx;
	line-height: 60rpx;
	background-color: #f7f7f7 !important;
	color: rgba(0, 0, 0, 0.3) !important;
	text-align: center;
	border-radius: 10rpx;
	margin: 0 auto;
	margin-top: 30rpx;
	margin-bottom: 20rpx;
}
</style>
